{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 33,
   "id": "3e41b31f",
   "metadata": {},
   "outputs": [],
   "source": [
    "from  scipy import stats\n",
    "import numpy as np\n",
    "import pandas as pd\n",
    "import matplotlib.pyplot as plt\n",
    "\n",
    "import tushare as ts\n",
    "from dateutil.parser import parse\n",
    "\n",
    "plt.rcParams['font.sans-serif'] = ['SimHei']\n",
    "plt.rcParams['axes.unicode_minus']=False # 负号问题"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "c436e1bd",
   "metadata": {},
   "outputs": [],
   "source": [
    "pro = ts.pro_api(\"0ba8feef618e5db7b1ebb65538fe51e4aef69fb3cbf709d44128f313\")\n",
    "code_sa = 'SA2209.ZCE'"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "5eceffb6",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "startdate = '20210101'\n",
    "enddate = '20220520'\n",
    "def init_df(df):\n",
    "    df['trade_date']= df['trade_date'].apply(parse)\n",
    "    df = df.set_index('trade_date')\n",
    "    return df\n",
    "df_sa = ( pro.query(\"fut_daily\", ts_code=code_sa, start_date=startdate, end_date=enddate))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "84a60c78",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>trade_date</th>\n",
       "      <th>return</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>20220510</td>\n",
       "      <td>-0.026970</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>20220509</td>\n",
       "      <td>0.053996</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>20220506</td>\n",
       "      <td>0.018443</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>20220505</td>\n",
       "      <td>0.026492</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>20220429</td>\n",
       "      <td>-0.018621</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "  trade_date    return\n",
       "1   20220510 -0.026970\n",
       "2   20220509  0.053996\n",
       "3   20220506  0.018443\n",
       "4   20220505  0.026492\n",
       "5   20220429 -0.018621"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_sa['return'] = (df_sa['close'] - df_sa['close'].shift(1) )/  df_sa['close'].shift(1) \n",
    "sa_return = df_sa[['trade_date','return']].dropna()\n",
    "sa_return.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 36,
   "id": "6bccb842",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\ldq\\AppData\\Local\\Temp\\ipykernel_40984\\2411605039.py:1: DeprecationWarning: Please use `gaussian_kde` from the `scipy.stats` namespace, the `scipy.stats.kde` namespace is deprecated.\n",
      "  density = stats.kde.gaussian_kde(sa_return.iloc[:,1])\n"
     ]
    }
   ],
   "source": [
    "density = stats.kde.gaussian_kde(sa_return.iloc[:,1])\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "id": "92755ea2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0x258c69e1e70>]"
      ]
     },
     "execution_count": 41,
     "metadata":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ZTYlKRESymhKViIhkNSUqERHJakpUIiKS1f4/5mXJ49adGFUAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 2 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "\n",
    "bins = np.arange(-0.5,0.5, 0.001)\n",
    "\n",
    "plt.subplot(211)\n",
    "plt.plot(bins, density(bins))\n",
    "plt.title('收益率序列的概率密度曲线图')\n",
    "plt.subplot(212)\n",
    "plt.plot(bins, density(bins).cumsum())\n",
    "plt.plot('累计分布函数图')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "8115616b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<matplotlib.collections.PathCollection at 0x258d16276d0>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYIAAAD2CAYAAADbPoDqAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAZwklEQVR4nO3db4xU153m8e/T7faqjbMBKwxSo/Q6miA2yWJspRR3DA4kMsL2KJHBkziJvcqL0RJlo7wYzyIbu6XEWWxnt7WeeJMYhRHSSl7MhCRMyaNkhoFlkIkdkLu3gU52jNBkbJKyWXu0EJZxr4fg377oKmiaqup7b1d1/bnPRyqp+tap4ldFq56+55x7jiICMzPLr55WF2BmZq3lIDAzyzkHgZlZzjkIzMxyzkFgZpZz17S6gLTe9773xY033tjqMszMOsrY2Ng/RsTiao91XBDceOONjI6OtroMM7OOIum1Wo+5a8jMLOccBGZmOecgMDPLOQeBmVnOOQjMzHKu42YNmZnlTXG8xMjeE7x+dpKBhf1sXr+ce25Z2rDXdxCYmbWx4niJLXsmmLxwEYDS2Um27JkAaFgYOAjM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/wVESsA04Dd1Z7D/NZa7U2SY81qs651ss8f64NqHfef2/nUm8rvheScBDUtxbYXb5/gKlfrlTtJC0FlkTEGDAEbJD0M0k7JTV6P4i51Futtk8AP46pGQX7gdvbpd6IeCYi9pWPLQberPEe5rPWam2SHmu0JP/GVW1a8LnOqd4atTX793Yu9QLz/r0wKwfBNOXTtMrp2UHga0Cp/PA5YEmNpy6o0+6rwLby/ZeBNRGxGjgL3N1G9Varrd77anW9ldf8OLAoIg7XeA+NkuSzqNYm6bFGy1ovMK+f61zrbfrvbYPrrWja90IWudmhLImI+PL0nyU9DVR2uL+e2sF5vlo7ST3AJyPikfJjxyPinfL9V4A5dQk0uN5qtVV9X21SL5JuAL4D3Ft+rKGfb5IaErRJeqzRstY735/rXOtt+u9tg+tt+vdCFj4jqG+My6dzK4FXU7a7HTgyrd2zklZK6gU2AMcaWWydOpK0q1Zb0teb93olXcvUafeWiKgsQtjMzzdJrdXaJD3WaJnqbcHnOqd6a9TWtp9v+f58fy/MLiJ8q3ED/mX5P+Up4O+A9wIfBrbO1q58/Alg47R2/wY4DkwAj7dTvdVqY+oPhReBp4ETwAfaqN6vAGeAg+Xbfc38fKvUsDJhnYmOzcPvQtJ65/VzbUC98/57O5d6y8fn9Xshyc1XFs9C0iJgHfBCRJyea7tma3S9kvqBPwD+Z0T8qt3rbaYkNVRrk/RYu9TbKo2st9m/t42ut9UcBGZmOecxAjOznHMQmJnlnIPAzCznHARmZjnnIDAzy7n/Dz3SWGy7aRmtAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.scatter(sa_return['return'], sa_return['return'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "267fec95",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "1     -0.026970\n",
       "2      0.053996\n",
       "3      0.018443\n",
       "4      0.026492\n",
       "5     -0.018621\n",
       "         ...   \n",
       "148    0.023336\n",
       "149   -0.030516\n",
       "150   -0.025251\n",
       "151    0.083038\n",
       "152   -0.027523\n",
       "Name: return, Length: 152, dtype: float64"
      ]
     },
     "execution_count": 48,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "sa_return['return']"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8dbea7a7",
   "metadata": {},
   "source": [
    "# 二项分布"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "13956138",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([41, 47, 60, 52, 43, 45, 57, 51, 55, 47, 52, 50, 56, 32, 51, 51, 58,\n",
       "       56, 60, 55])"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "np.random.binomial(100,0.5, 20) # n, p, size:  n 进行伯努利实验的次数； p 取值为1的概率， size生成随机数的数量\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "db0e7464",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "4.2281632676015645e-10"
      ]
     },
     "execution_count": 51,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 正面向上的概率是0.5， 投100次硬币， 20次正面朝上的概率是多少？\n",
    "stats.binom.pmf(20, 100, 0.5)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "a008a13a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "5.579544528625976e-10"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 正面向上的概率是0.5， 投100次硬币， 正面朝上的次数小于等于20次的概率是多少？\n",
    "stats.binom.cdf(20, 100, 0.5)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8269b2e3",
   "metadata": {},
   "source": [
    "# 正态分布"
   ]
  },
  {
   "cell_type": "raw",
   "id": "45cac32c",
   "metadata": {},
   "source": [
    "又名： 高斯分布 \n",
    "收益率： 正态分布或者对数正态分布\n",
    "normal\n",
    "normal（loc, scale=1.0, size=None）\n",
    "loc: 均值\n",
    "scale： 标准差， 默认1\n",
    "size： 随机数数量"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "749da30a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "trader",
   "language": "python",
   "name": "trader"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
